#ifndef frm_control_TFrame_H
#define frm_control_TFrame_H

#include "frm_control_TScrollBar.h"
#include "frm_control_TMover.h"
#include "frm_control_TTable.h"

namespace frm { namespace control {

///////////////////////////////////////////////////////////////////////////////
struct TFrame;
///////////////////////////////////////////////////////////////////////////////

struct TFrameClient : public TPanel
{
  struct TStyle : public TPanel::TStyle
  {
    svl_Type(TPanel::TStyle)
  };
  TFrame &Frame;
  //
  TFrameClient(TWindow &Window,TFrame &Frame_) : TPanel(Window),Frame(Frame_) {}
  //
  void TComponent_InheritStyleFrom(TTableOfStyles &ParentStyles);

/****************
  virtual void TComponent_MouseWheel(TMouseWheel MouseWheel)
  {
    //::MessageBeep(0);
    SetCursor(LoadCursor(NULL,IDC_CROSS));
  }
  virtual void TComponent_Mouse(TMouse Mouse)
  {
    ::MessageBeep(0);
    SetCursor(LoadCursor(NULL,IDC_CROSS));
  }
********************/
  
};

///////////////////////////////////////////////////////////////////////////////

struct TFramePanelScroll : public TPanel
{
  struct TStyle : public TPanel::TStyle
  {
    svl_Type(TPanel::TStyle)
  };
  //
  TFramePanelScroll(TWindow &Window) : TPanel(Window) {}
  //
  void TComponent_InheritStyleFrom(TTableOfStyles &ParentStyles);
};

////////////////////////////////////////////////////////////////////////////////

struct TFrame : public TPanel
{
  struct TStyle : public TPanel::TStyle
  {
    TScrollBarHorz::TStyle    HScroll;
    TScrollBarVert::TStyle    VScroll;
    TFramePanelScroll::TStyle PanelScroll;
    TFrameClient     ::TStyle Client;
    
    TSplitterBoth::TStyle ResizeRBSplitter;
    TMover::TStyleRB      ResizeRBMover;
    //
    TStyle();
    //
    virtual void SetFromParent(frm::TStyle *Parent);
    virtual svl::TInfoParam AddInfoTo(svl::TInfoParam Info);
  };
  //
  TPanel                *PanelV;
  TFramePanelScroll       *PanelScroll;
  TFrameClient              *Client;
  TScrollBarHorz          *HScroll;
  TPanel                *panelVS;
  TScrollBarVert          *VScroll;
  TPanel                  *resizeRB;
  //
  TPanelSelect  PanelSelect;
  virtual TPanelSelect *TComponent_GetPanelSelect() { return &PanelSelect;}
  //
  TFrame(TWindow &Window,bool FormResize = false);
 ~TFrame();
  svl_Type(TPanel)
  //
  TFrame &SetStyle(TStyle &V);
  //
  void ScrollToVisibleRect(TPanel &Component,grf::TRect Rect);
  //
  TScrollBar::TEvents &GetScrollEvents() { return scrollEvents; }

private:
  virtual void TComponent_MouseWheel(TMouseWheel MouseWheel);
  //
  void TComponent_InheritStyleFrom(TTableOfStyles &ParentStyles);
  //
  struct TScrollEvents : public TScrollBar::TEvents
  {
    TFrame &frame; TScrollEvents(TFrame &M) : frame(M) {}
    virtual void TEvents_AfterScroll(TI&I,TScrollBar &Sender,int NewPosition);
  }
  scrollEvents; friend TScrollEvents;
  //
  struct TResizeClient : public geometry::TOrdinate::TEvents
  {
    TFrame &frame; TResizeClient(TFrame &M) : frame(M) {}
    virtual void TEvents_BeforeChangeSize(geometry::TOrdinate &Sender,int OldVal,int &NewVal);
  }
  resizeClient; friend TResizeClient;
  //
  struct TResizePanelScroll : public geometry::TOrdinate::TEvents
  {
    TFrame &frame; TResizePanelScroll(TFrame &M) : frame(M) {}
    virtual void TEvents_BeforeChangeSize(geometry::TOrdinate &Sender,int OldVal,int &NewVal);
  }
  resizePanelScroll; friend TResizePanelScroll;
  //
  svl_Except;
};

///////////////////////////////////////////////////////////////////////////////

}}

#endif
